import wepy from 'wepy'

export default class extends wepy.mixin {
  data = {
    swiper: [],
    navCate: [],
    floor: []
  }

  config = {
  }

  methods = {
    // 跳转到商品列表
    goGoodsList (url) {
      wepy.navigateTo({url})
    }
  }
  async getSwiper () {
    const { data:res } = await wepy.get('/home/swiperdata')
    if (res.meta.status !== 200) return wepy.baseToast()
    this.swiper = res.message
    this.$apply()
  }
  async getCates () {
    const { data:res } = await wepy.get('/home/catitems')
    if (res.meta.status !== 200) return wepy.baseToast()
    this.navCate = res.message
    this.$apply()
  }
  async getFloorData () {
    const { data:res } = await wepy.get('/home/floordata')
    if (res.meta.status !== 200) return wepy.baseToast()
    this.floor = res.message
    this.$apply()

  }
  onLoad () {
    console.log('123')
    this.getSwiper()
    this.getCates()
    this.getFloorData()
  }
  onShow () {
    this.$parent.setTabbatBadge()
  }
}
